WEBVTT 00:00.000 --> 00:14.840 This is Hacker Public Radio Episode 3,889 for Thursday, the 29th of June 2023. 00:14.840 --> 00:21.120 Today's show is entitled, Common Compaired Two Sorted Files Line by Line. 00:21.120 --> 00:25.520 It is hosted by Ken Fallon and is about three minutes long. 00:25.520 --> 00:28.120 It carries a clean flag. 00:28.120 --> 00:35.120 The summary is a great tool to quickly find the differences between two files. 00:40.600 --> 00:46.400 Hi everybody, my name is Ken Fallon and you're listening to another episode of Hacker Public Radio. 00:46.400 --> 00:53.600 Today I want to share with you a little command line tool that I've been using very often recently. 00:53.600 --> 01:01.840 It was shown to me by Paul Samwork and it is called Common COMM from the ManPage. 01:01.840 --> 01:05.600 It says Compare Two Sorted Files Line by Line. 01:05.600 --> 01:08.600 The Sorted is very important there. 01:08.600 --> 01:15.720 It's part of the core Util packages, which you can install on Fedora Red Hat systems using 01:15.720 --> 01:23.760 DNF and Stoll Core Utils or Mob Word and on Debian Apped Install Core Utils or Mob Word. 01:23.760 --> 01:28.600 I'll read you a little bit of the command file here to get us going. 01:28.600 --> 01:33.240 So it's calm space and then options and then the first file and the second file. 01:33.240 --> 01:38.640 So you can pair sort of files, file one and file two line by line. 01:38.640 --> 01:45.320 Then file one or file two, not both is dash, read from standard input. 01:45.320 --> 01:51.160 With no options, produces three column output, column one contains lines unique to file 01:51.160 --> 01:59.080 one, column two contains lines unique to file two and column three contains lines common 01:59.080 --> 02:00.080 to both files. 02:00.080 --> 02:01.360 So that's a standard. 02:01.360 --> 02:08.560 But what you can also do is you can use the option stash one, dash two and dash three. 02:08.560 --> 02:14.840 And dash one will suppress column one, showing only the lines unique to file one, column 02:14.840 --> 02:20.560 dash two will suppress column two, showing only those unique to file two. 02:20.560 --> 02:24.920 So there are some other options, but I always found it a little bit confusing, so it's 02:24.920 --> 02:29.160 a lot easier just to create two different files. 02:29.160 --> 02:34.800 The first file having the number one on the first line and the number two and the second 02:34.800 --> 02:35.800 line. 02:35.800 --> 02:41.440 I call that on imagine this is really one and two dash text and then I create another 02:41.440 --> 02:47.280 file called two and three dash text and I have the number two on the first line and the 02:47.280 --> 02:49.400 number three on the first line. 02:49.400 --> 02:58.920 So if you run that command with calm space dash one, space dash two using one and two 02:58.920 --> 03:02.280 dash text and two and three dash text, you get the number two. 03:02.280 --> 03:05.480 So that's showing you the ones that are common to both. 03:05.480 --> 03:09.000 So what's left over is line three. 03:09.000 --> 03:14.600 If you do calm dash one, calm dash two, you get the number three which is makes sense. 03:14.600 --> 03:23.280 So this is in the show what's and it is an extremely useful file for comparing, yeah, 03:23.280 --> 03:29.240 I don't know, for example, hypothetically speaking, if you are moving a server from one location 03:29.240 --> 03:32.120 to another and you wanted to make sure you have all the files. 03:32.120 --> 03:39.960 You can sort the text from the name of all the files from one and against two and very quickly 03:39.960 --> 03:41.120 get an output. 03:41.120 --> 03:43.360 So that's it. 03:43.360 --> 03:45.760 Feel free to send in some shows. 03:45.760 --> 03:51.560 We are now able to add to the reserve queue so feel free to do that and tune in tomorrow 03:51.560 --> 03:59.120 for another exciting episode of Hacker, a public radio. 03:59.120 --> 04:04.080 You have been listening to Hacker Public Radio at HackerPublicRadio.org. 04:04.080 --> 04:08.080 Today's show was contributed by a HBR this night like yourself. 04:08.080 --> 04:14.480 If you ever thought of recording podcast, click on our contributally to find out how easy it 04:14.480 --> 04:15.480 means. 04:15.480 --> 04:22.880 Hosting for HBR has been kindly provided by an onsthost.com, the internet archive and our 04:22.880 --> 04:23.880 synced.net. 04:23.880 --> 04:30.360 On this otherwise stages, today's show is released on our Creative Commons, Attribution 04:30.360 --> 04:32.440 for Pointo International License.